package com.msc.mobilecomputing.fragments;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.msc.mobilecomputing.R;
import com.msc.mobilecomputing.model.TravelLocation;

public class DescriptionFragment extends Fragment {

	public static final String EXTRA = "location";

	private TravelLocation location;
	
	private Context context;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		location = (TravelLocation) getArguments().get(EXTRA);
		this.context = getActivity();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View view = inflater.inflate(R.layout.fragment_desciption, container,
				false);

		TextView title = (TextView) view
				.findViewById(R.id.frag_description_text_title);
		TextView desription = (TextView) view
				.findViewById(R.id.frag_description_text_description);

		ImageView imageBackground = (ImageView) view
				.findViewById(R.id.frag_description_image_background);
		ImageView image = (ImageView) view
				.findViewById(R.id.frag_description_image);

		if (location != null) {
			title.setText(location.getName());
			desription.setText(context.getString(location.getDescription()));
			imageBackground.setImageResource(location.getImageResource());
			image.setImageResource(location.getImageBackground());
		}

		return view;
	}

}
